/**
 * 
 */
package com.swg.cocobox.message.internal;

import java.io.Serializable;
import java.nio.channels.SocketChannel;

import com.swg.cocobox.message.ClientInfo;

/**
 * @author satriaprayoga
 *
 */
public class SimpleClientInfo implements ClientInfo,Serializable{

	private static final long serialVersionUID = 8719056638177135043L;
	
	private final String username;
	private final String password;
	private SocketChannel channel;
	
	public SimpleClientInfo(String username,String password) {
		this.username=username;
		this.password=password;
	}
	
	public SimpleClientInfo(String username,String password,SocketChannel channel) {
		this(username,password);
		this.channel=channel;
	}

	@Override
	public String getUsername() {
		return username;
	}

	@Override
	public String getPassword() {
		return password;
	}

	@Override
	public SocketChannel getChannel() {
		return channel;
	}

	@Override
	public void setChannel(SocketChannel channel) {
		this.channel=channel;
	}

	@Override
	public String toString() {
		return "ClientInfo [username=" + username + ", password="
				+ password + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((password == null) ? 0 : password.hashCode());
		result = prime * result
				+ ((username == null) ? 0 : username.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SimpleClientInfo other = (SimpleClientInfo) obj;
		if (password == null) {
			if (other.password != null)
				return false;
		} else if (!password.equals(other.password))
			return false;
		if (username == null) {
			if (other.username != null)
				return false;
		} else if (!username.equals(other.username))
			return false;
		return true;
	}
	
	
}
